<?php
class SSKString {
	protected $value = null;
	
	public function __construct($value = null) {
		$this->value = $value;
	}
	public function __toString() {
		if($this->value) {
			return $this->value;
		} else {
			return "";
		}
	}
	public function __invoke($value) {
		$this->value = $value;
	}
	public function toArray() {
		if($this->value) {
			$charr=array();
			$charr=str_split($this->value, 1);
			return $charr;
		} else {
			return "";
		}
	}
	public function Append($append) {
		$this->value.=$append;
	}
	public function Substring($start, $length=null) {
		if($this->value) {
			if(!$length) {
				$substr=substr($this->value, $start);
			} else {
				$substr=substr($this->value, $start, $length);
			}
			return $substr;
		} else {
			return "";
		}
	}
	public function Length() {
		$strlen=strlen($this->value);
		return $strlen;
	}
	public function toLower() {
		$this->value=strtolower($this->value);
	}
	public function toUpper() {
		$this->value=strtoupper($this->value);
	}
	public function Compare($string, $caseinsensitive=false, $length=null) {
		if($caseinsensitive) {
			if($length) {
				$cmp=strncasecmp($this->value, $string, $length);
			} else {
				$cmp=strcasecmp($this->value, $string);
			}
		} else {
			if($length) {
				$cmp=strncmp($this->value, $string, $length);
			} else {
				$cmp=strcmp($this->value, $string);
			}
		}
		return $cmp;
	}
	public function Trim($charlist=null) {
		if($charlist) {
			$this->value=trim($this->value, $charlist);
		} else {
			$this->value=trim($this->value);
		}
	}
	public function Explode($delimiter, $limit=null) {
		if($limit) {
			$explode=explode($delimiter, $this->value, $limit);
		} else {
			$explode=explode($delimiter, $this->value);
		}
		return $explode;
	}
	public function Implode($pieces, $glue=null) {
		if($glue) {
			$this->value=implode($glue, $pieces);
		} else {
			$this->value=implode($pieces);
		}
	}
	public function Split($limit) {
		$split=str_split($this->value, $limit);
		return $split;
	}
}
?>